package promote.brozen.base.collection;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Brozen
 * @date 2020/9/14 5:05 PM
 * @email brozen@qq.com
 */
public class ConcurrentMapIter {


    public static void main(String[] args) throws InterruptedException {
//         Map<String, String> map = new ConcurrentHashMap<>();
         Map<String, String> map = new HashMap<>();
         map.put("a", "a");
         map.put("b", "b");
         map.put("c", "c");

        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println(entry.getKey());

            if (entry.getKey().equals("b")) {
                Thread t = new Thread(() -> map.remove("c"));
                t.start();
                t.join();
            }
        }

    }



}
